package io.renren.modules.yckj.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.yckj.dao.AssetLogDao;
import io.renren.modules.yckj.dto.AssetLogDTO;
import io.renren.modules.yckj.entity.AssetLogEntity;
import io.renren.modules.yckj.service.AssetLogService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 用户资产记录
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2025-04-27
 */
@Service
public class AssetLogServiceImpl extends CrudServiceImpl<AssetLogDao, AssetLogEntity, AssetLogDTO> implements AssetLogService {

    @Override
    public QueryWrapper<AssetLogEntity> getWrapper(Map<String, Object> params) {
        String id = (String) params.get("id");
        Object userId = params.get("userId");
        Object username = params.get("username");
        Object type = params.get("type");
        Object businessType = params.get("businessType");


        QueryWrapper<AssetLogEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.like(ObjectUtil.isAllNotEmpty(username), "username", username);
        wrapper.eq(ObjectUtil.isAllNotEmpty(type), "type", type);
        wrapper.eq(ObjectUtil.isAllNotEmpty(userId), "user_id", userId);
        wrapper.eq(ObjectUtil.isAllNotEmpty(businessType), "business_type", businessType);
        wrapper.orderByDesc("id");
        return wrapper;
    }


}